<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">

<title>class User - Rails Application Documentation</title>

<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
</script>

<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="./index.html">Home</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>app/models/user.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link">ActiveRecord::Base
  
</nav>

    
    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-c-authenticate">::authenticate</a>
    
    <li><a href="#method-c-encrypt">::encrypt</a>
    
    <li><a href="#method-c-random_string">::random_string</a>
    
    <li><a href="#method-i-password-3D">#password=</a>
    
    <li><a href="#method-i-send_new_password">#send_new_password</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="./doc/README_FOR_APP.html">README_FOR_APP</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="./ApplicationController.html">ApplicationController</a>
  
    <li><a href="./ApplicationHelper.html">ApplicationHelper</a>
  
    <li><a href="./Comment.html">Comment</a>
  
    <li><a href="./CommentsController.html">CommentsController</a>
  
    <li><a href="./CommentsHelper.html">CommentsHelper</a>
  
    <li><a href="./Event.html">Event</a>
  
    <li><a href="./EventsController.html">EventsController</a>
  
    <li><a href="./EventsHelper.html">EventsHelper</a>
  
    <li><a href="./Group.html">Group</a>
  
    <li><a href="./HomeController.html">HomeController</a>
  
    <li><a href="./HomeHelper.html">HomeHelper</a>
  
    <li><a href="./InviteeList.html">InviteeList</a>
  
    <li><a href="./InviteeListsController.html">InviteeListsController</a>
  
    <li><a href="./InviteeListsHelper.html">InviteeListsHelper</a>
  
    <li><a href="./Location.html">Location</a>
  
    <li><a href="./LocationsController.html">LocationsController</a>
  
    <li><a href="./LocationsHelper.html">LocationsHelper</a>
  
    <li><a href="./Notification.html">Notification</a>
  
    <li><a href="./Organization.html">Organization</a>
  
    <li><a href="./Post.html">Post</a>
  
    <li><a href="./PostsController.html">PostsController</a>
  
    <li><a href="./PostsHelper.html">PostsHelper</a>
  
    <li><a href="./Response.html">Response</a>
  
    <li><a href="./ResponsesController.html">ResponsesController</a>
  
    <li><a href="./ResponsesHelper.html">ResponsesHelper</a>
  
    <li><a href="./User.html">User</a>
  
    <li><a href="./UsersController.html">UsersController</a>
  
    <li><a href="./UsersHelper.html">UsersHelper</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class User</h1>

  <div id="description" class="description">
    
  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    
    <!-- Attributes -->
    <section id="attribute-method-details" class="method-section section">
      <h3 class="section-header">Attributes</h3>

      
      <div id="attribute-i-password" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">password</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-password_confirmation" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">password_confirmation</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
    </section><!-- attribute-method-details -->
    

    <!-- Methods -->
    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Class Methods</h3>

    
      <div id="method-c-authenticate" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">authenticate</span><span
            class="method-args">(email, pass)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="authenticate-source">
            <pre><span class="ruby-comment"># File app/models/user.rb, line 48</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">authenticate</span>(<span class="ruby-identifier">email</span>, <span class="ruby-identifier">pass</span>)
    <span class="ruby-identifier">u</span>=<span class="ruby-identifier">find</span>(<span class="ruby-value">:first</span>, <span class="ruby-value">:conditions=</span><span class="ruby-operator">&gt;</span>[<span class="ruby-string">&quot;email = ?&quot;</span>, <span class="ruby-identifier">email</span>])
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">u</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">u</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">User</span>.<span class="ruby-identifier">encrypt</span>(<span class="ruby-identifier">pass</span>, <span class="ruby-identifier">u</span>.<span class="ruby-identifier">salt</span>)<span class="ruby-operator">==</span><span class="ruby-identifier">u</span>.<span class="ruby-identifier">hashed_password</span>
    <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- authenticate-source -->
          
        </div>

        

        
      </div><!-- authenticate-method -->

    
    </section><!-- public-class-method-details -->
  
     <section id="protected-class-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Protected Class Methods</h3>

    
      <div id="method-c-encrypt" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">encrypt</span><span
            class="method-args">(pass, salt)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="encrypt-source">
            <pre><span class="ruby-comment"># File app/models/user.rb, line 42</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">encrypt</span>(<span class="ruby-identifier">pass</span>, <span class="ruby-identifier">salt</span>)
    <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA1</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">pass</span><span class="ruby-operator">+</span><span class="ruby-identifier">salt</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- encrypt-source -->
          
        </div>

        

        
      </div><!-- encrypt-method -->

    
      <div id="method-c-random_string" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">random_string</span><span
            class="method-args">(len)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="random_string-source">
            <pre><span class="ruby-comment"># File app/models/user.rb, line 25</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">random_string</span>(<span class="ruby-identifier">len</span>)
    <span class="ruby-identifier">chars</span> = (<span class="ruby-string">&quot;a&quot;</span><span class="ruby-operator">..</span><span class="ruby-string">&quot;z&quot;</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-string">&quot;a&quot;</span><span class="ruby-operator">..</span><span class="ruby-string">&quot;Z&quot;</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-string">&quot;0&quot;</span><span class="ruby-operator">..</span><span class="ruby-string">&quot;9&quot;</span>).<span class="ruby-identifier">to_a</span>
    <span class="ruby-identifier">newpass</span> = <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-value">1</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-identifier">len</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">newpass</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">chars</span>[<span class="ruby-identifier">rand</span>(<span class="ruby-identifier">chars</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>)] }
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">newpass</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- random_string-source -->
          
        </div>

        

        
      </div><!-- random_string-method -->

    
    </section><!-- protected-class-method-details -->
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-password-3D" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">password=</span><span
            class="method-args">(pass)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="password-3D-source">
            <pre><span class="ruby-comment"># File app/models/user.rb, line 34</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">password=</span>(<span class="ruby-identifier">pass</span>)
    <span class="ruby-ivar">@password</span>=<span class="ruby-identifier">pass</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">salt</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">random_string</span>(<span class="ruby-value">10</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">hashed_password</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">encrypt</span>(<span class="ruby-ivar">@password</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">salt</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- password-3D-source -->
          
        </div>

        

        
      </div><!-- password-3D-method -->

    
      <div id="method-i-send_new_password" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">send_new_password</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="send_new_password-source">
            <pre><span class="ruby-comment"># File app/models/user.rb, line 55</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">send_new_password</span>
  <span class="ruby-identifier">new_pass</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">random_string</span>(<span class="ruby-value">10</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">password</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">password_confirmation</span> = <span class="ruby-identifier">new_pass</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">save</span>
  <span class="ruby-constant">Notifications</span>.<span class="ruby-identifier">deliver_forgot_password</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">email</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">login</span>, <span class="ruby-identifier">new_pass</span>)
<span class="ruby-keyword">end</span></pre>
          </div><!-- send_new_password-source -->
          
        </div>

        

        
      </div><!-- send_new_password-method -->

    
    </section><!-- public-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

